const func = (str) => {
    let temp = '-1'
    let count = 0
    let maxCount = 0
    // 传入的字段串增加一位，防止以连续字母结尾的统计出错
    str += '-1'
    const res = {}
    
    while(str.length > 0) {
      // 相同字符串，统计+1
      if (temp === str[0]) {
        count ++
        res[temp] = count
      } else {
        // 遇到不同，比较当前连续的字符是否是最长的
        if (res[temp] >= maxCount) {
          maxCount = res[temp]
        } else {
          delete res[temp]
        }
        count = 1
        temp = str[0]
      }
      str = str.substring(1)
    }
    return res
  }
  
  // const str = 'abbkejsbcccwqaa'
  const str = 'abcaakjbb'
  const res = func(str)
  console.log('res', res)